define(['text!service/tipsList.html', '../service/data/tips'],
	function(viewTemplate, Tips) {
		return Piece.View.extend({
			id: 'service_tipsList',
			events: {
				"click .view": "view",
				"click #submit": "submit",
				"click .ebtitlebg": "ebdateHeaderClick",
				"click .list-st": "runTemplateItemClick"
			},
			render: function() {
				$(this.el).html(viewTemplate);

				Piece.View.prototype.render.call(this);
				return this;
			},
			onShow: function() {
				//write your business logic here :)
				console.info(Tips);

				var windowHeight = $(window).height();
				var elTop = $("#appliances").offset().top;
				var elHeight = windowHeight - elTop;

				console.info(elHeight);
				$("#appliances").css({
					"height": elHeight
				});
				new iScroll($("#appliances")[0]);
				this.TempviewlateRender(Tips);


			},

			view: function(e) {

				this.container.navigateForResult('/service/tips', {
					trigger: true
				}, 'service/tipsList', this.onGotResult);
			},
			submit: function() {
				this.container.navigateForResult('/service/tips', {
					trigger: true
				}, 'service/tipsList', this.onGotResult);

			},

			//模板页面渲染

			TempviewlateRender: function(data) {
				console.info(data.maintainList);
				var listTemplateWiki = _.template($("#appliancesTemp").html(), {
					"rows": data.maintainList
				});

				$("#maintainList").append(listTemplateWiki);



				var listTemplateWiki1 = _.template($("#appliancesTemp").html(), {
					"rows": data.questionList
				});



				$("#questionList").append(listTemplateWiki1);

				var listTemplateWiki2 = _.template($("#appliancesTemp").html(), {
					"rows": data.operationList
				});



				$("#operationList").append(listTemplateWiki2);
				var listTemplateWiki3 = _.template($("#appliancesTemp").html(), {
					"rows": data.faultList
				});

				$("#faultList").append(listTemplateWiki3);


				// new iScroll($("#standards"));
			},



			ebdateHeaderClick: function(e) {
				var el = $(e.currentTarget);
				//$('.extendBlock').hide();
				var me = this;
				var type = el.attr('state');

				console.info("================" + type);
				var hadExtend = false;
				if (el.hasClass('select')) {
					hadExtend = true;
				}
				$('.ebtitlebg').removeClass('select');
				if (hadExtend) {
					console.log('yes');

					$('#' + type).hide();

				} else {
					console.log('no');
					el.addClass('select');


					$('.ebtask').hide();
					$('#' + type).show();
				}



			},


			runTemplateItemClick: function(e) {
				// var el = e.currentTarget;

				// var type = $(el).attr('key');

				// var tab = null;
				// var noticeText = null;
				// var state = $(el).attr('state');
				// var id = null;

				this.container.navigateForResult('/service/tips', {
					trigger: true
				}, 'service/tipsList', this.onGotResult);

			},



		}); //view define

	});